// Assertion in union type
{
  interface Cat {
    name: string;
    run(): void;
  }

  interface Fish {
    name: string;
    swim(): void;
  }

  function getName(animal: Cat | Fish): string {
    return animal.name;
  }

  function isFish(animal: Cat | Fish): boolean {
    if (typeof (animal as Fish).swim === "function") {
      return true;
    } else {
      return false;
    }
  }
}

// Assertion as sub-type
{
  interface ApiError extends Error {
    code: number;
  }
  interface HttpError extends Error {
    statusCode: number;
  }

  function isApiError(error: Error) {
    if (typeof (error as ApiError).code === "number") {
      return true;
    }
    return false;
  }
}

// Assertion as any
// Assertion from any
// Double assertion
